//package com.cyn.service.impl;
//
//import com.cyn.entity.SysUser;
//import com.cyn.entity.system.UserDO;
//import com.cyn.service.UserService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.GrantedAuthority;
//import org.springframework.security.core.authority.SimpleGrantedAuthority;
//import org.springframework.security.core.userdetails.User;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.ArrayList;
//import java.util.List;
//
////自定义userdetailservice
//@Service
//public class UserDetailServiceImpl implements UserDetailsService {
//
//    @Autowired
//    UserService userService;
//    @Autowired
//    PasswordEncoder passwordEncoder;
//
//    @Transactional
//    @Override
//    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//        UserDO sysUser = userService.get(1l);
//        List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
//        if (sysUser != null) {
////            System.err.println("sysUser===============" + sysUser);
////            //获取用户的授权
////            List<Permission> permissions = permissionService.findByAdminUserId(sysUser.getId());
////            //声明授权文件
////            for (Permission permission : permissions) {
////                if (permission != null && permission.getName() != null) {
////                    GrantedAuthority grantedAuthority = new SimpleGrantedAuthority("ROLE_" + permission.getName());
////                    grantedAuthorities.add(grantedAuthority);
////                }
////            }
//        }
//        System.err.println("grantedAuthorities===============" + grantedAuthorities);
//        return new User(sysUser.getName(), "$2a$10$SmAL0OO/buB.gE/Mi9PMSOW5rNl0xXIScWkq4/OhdRUdV7mNHnqwi", grantedAuthorities);
//    }
//
//    public static void main(String[] args) {
//        System.out.println(new BCryptPasswordEncoder().encode("123456"));
//    }
//}